/*
 This file 'zdwxyDialogApp' is part of Firebird Integrated Solution 1.0

 Copyright (c) 2020 Lincong

 Contact:  
        Email: lincong1987@gmail.com

        QQ: 159257119
 
 See Usage at http://www.jplatformx.com/firebird

 Create date: 2020-07-20 19:05
 */


define(function (require, exports, module) {
	require("Firebird.App");
	require("Firebird.Controller");

	require("../assets/pager2");

	var controller = Firebird.create("Firebird.Controller", {
		controller: "{contextPath}/publicMain"
	});

	Firebird.define("zdwxy.zdwxyDialogApp", {
		extend: "Firebird.SearchApp",
		controller: controller,
		setContext: function () {
			var app = this, context = this.context;
			$(".close_dialog_button").on("click", this.closeDialog);


			$("#J_pager2").pager2({
				renderTo: "#J_pager2",
				url: "../resource/app/zdwxy/data.json",
				pageParam: {
					page: 1,
					size: 10,
				},
				param: {},

				show: {
					first: false,
					last: false,
					detail: true
				},

				lang: {
					start: 1,
					end: 1
				},
				onSuccess: function (json) {
					$("#J_list").html(require("./list.tmpl")(json));
				}
			});


			// 标签 切换
			$(".tab").each(function () {
				var $this = $(this);
				$this.on("click", "a", function (e) {
					e.preventDefault();
					var $a = $(e.target).is("a") ? $(e.target) : $(e.target).closest("a");
					if (!$a.parent().hasClass("tab-header")) {
						return;
					}
					var index = $this.find("a").index($a);
					$a.addClass("active").siblings().removeClass("active")
					$this.find(".tab-content .content").eq(index).addClass("active").siblings().removeClass("active");
				});
			});


		},

		listener: {},
		closeDialog: function () {
			_top.$.dialog.get(window).close();
		},
	});


});